<?php

declare(strict_types=1);

namespace Modules\Production\Models;

use Catch\Base\CatchModel as Model;

/**
 * @property $id
 * @property $order_id
 * @property $material_no
 * @property $lot_num
 * @property $qty
 * @property $pick_order_no
 * @property $creator_id
 * @property $created_at
 * @property $updated_at
 * @property $deleted_at
*/
class MaterialReturnPlanDetail extends Model
{


    protected $table = 'material_return_plan_detail';

    protected $fillable = [ 'id', 'order_id', 'material_no','supplier_code','wms_code','source_lot_num','location', 'lot_num', 'qty', 'pick_order_no', 'creator_id', 'created_at', 'updated_at', 'deleted_at' ];

    /**
     * @var array
     */
    protected array $fields = ['id','order_id','material_no','supplier_code','wms_code','source_lot_num','location','lot_num','qty','pick_order_no','created_at','updated_at'];

    /**
     * @var array
     */
    protected array $form = ['id','order_id','material_no','supplier_code','wms_code','source_lot_num','location','lot_num','qty','pick_order_no','created_at','updated_at'];

    /**
     * @var array
     */
    public array $searchable = [
        'order_id' => '=',
        'material_no' => '=',

    ];

    /**
     * 时间格式化
     * @param $date
     * @return mixed
     */
    protected function serializeDate($date)
    {
        return $date->format('Y-m-d H:i');
    }

    /**
     * 关联生产退料计划表头
     * @return mixed
     */
    public function order(){
        return $this->belongsTo(MaterialReturnPlanOrder::class,'order_id');
    }
}
